package com.zxy.controller;

import com.zxy.entity.Product;
import com.zxy.feignclient.ProductClient;
import com.zxy.vo.CollectionVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author: Zxy
 * @Date: 2021-06-09
 **/
@RestController
public class CategoryController {

    private static final Logger log = LoggerFactory.getLogger(CategoryController.class);

    @Value("${server.port}")
    private int port;

    @Autowired
    private ProductClient productClient;

    @GetMapping("/category")
    public String category() {
        log.info("category服务启动成功");
        String product = productClient.product();
        System.out.println(product);
        return "category ok" + port;
    }

    // 调用product服务的test1接口传递参数 使用queryString
    @GetMapping("/test1")
    public String testQueryString(String name, Integer age) {
        return productClient.testQueryString(name, age);
    }

    // 调用product服务的test1接口传递参数 使用pathVarible
    @GetMapping("/test2")
    public String testPathVarible(String name, Integer age) {
        return productClient.testPathVarible(name, age);
    }

    // 调用product服务的test1接口传递参数 使用对象传参
    @PostMapping("/test3")
    public String testJavaBean() {
        return productClient.testJavaBean(new Product(1, "超短裙", 23.3, new Date()));
    }

    // 调用product服务的test1接口传递参数 使用数组传参
    @GetMapping("/test4")
    public String testArrays() {
        return productClient.testArrays(new String[]{"1", "2", "3", "4"});
    }

    // 调用product服务的test1接口传递参数 使用集合传参
    @GetMapping("/test5")
    public String testList() {
        return productClient.testList(new String[]{"1", "2", "3", "4"});
    }

}
